using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SelectParametersPage : System.Web.UI.Page
{
    GridView gridView;     
    SqlDataSource sqlDatatSource ;
    protected void Page_Load(object sender, EventArgs e)
    {
            sqlDatatSource = new SqlDataSource();
            sqlDatatSource.ConnectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            sqlDatatSource.SelectCommandType =
            SqlDataSourceCommandType.Text;                         
            gridView = new GridView();
            this.form1.Controls.Add(gridView);
            AddParameter("Ho Chi Minh");               
    }
     
    void AddParameter(string cityName)
    {
        
        sqlDatatSource.SelectCommand =
        "select UserID,Email, FirstName," +
        "LastName,City from tblJSAccounts " +
        " where City=@City ";
        sqlDatatSource.SelectParameters.Add(
        "City", TypeCode.String, cityName);        
        gridView.DataSource = sqlDatatSource;
        gridView.DataBind();
        
    }

    void AddParameterByParameterObject(string cityName)
    {

        sqlDatatSource.SelectCommand =
        "select UserID,Email, FirstName," +
        "LastName,City from tblJSAccounts " +
        " where City=@City ";
        Parameter parameter = new 
        Parameter("City", TypeCode.String, cityName);
        sqlDatatSource.SelectParameters.Add(parameter);

        gridView.DataSource = sqlDatatSource;
        gridView.DataBind();

    }

}
